package com.jieshuibao.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jieshuibao.common.res.BaseRes;
import com.jieshuibao.model.db.Version;
import com.jieshuibao.model.domain.VersionRes;
import com.jieshuibao.service.VersionService;

@Controller
@RequestMapping(value="/version")
public class VersionController {
	
	@Resource
	private VersionService versionService;
	
	//电视盒子更新版本
	@RequestMapping(value="/tvcode",method = RequestMethod.POST)
	@ResponseBody
	public Object iosReleasVersion(HttpServletRequest request){
		VersionRes versionRes = new VersionRes();
		
		try {
			List<Version> versionCode = versionService.getVersionCode();
			Version version = versionCode.get(0);
			versionRes.setData(version);
			versionRes.setCode(BaseRes.SUCCESS_CODE);
			versionRes.setDes(BaseRes.SUCCESS_DES);
		} catch (Exception e) {
			e.printStackTrace();
			versionRes.setCode(BaseRes.FAIL_CODE);
			versionRes.setDes(BaseRes.FAIL_DES);
		}
		return versionRes;
	}
}
